#include "../app/app_buffer.h"
#include "log/log.h"

int main(int argc, char const *argv[])
{
    //写缓存数据1
    Buffer *buffer1 = app_buffer_init(16);
    app_buffer_write(buffer1, "hello world", 11);

    //写缓存数据2
    app_buffer_write(buffer1, "hi", 2);

    //读取缓存数据1
    char data1[16];
    int data_len1=app_buffer_read(buffer1, data1, 11);
    //.*s表示打印data_len1个字符（解决无结束标记）
    log_debug("data1值为: %.*s",data_len1, data1);  

    //读取缓存数据2
    char data2[6];
    int data_len2=app_buffer_read(buffer1, data2, 2);
    log_debug("data2值为: %.*s",data_len2, data2);
    
    //读取缓存数据3
    char data3[16];
    int data_len3=app_buffer_read(buffer1, data3, 11);
    log_debug("data3值为: %.*s",data_len3, data3);

    //释放缓存
    app_buffer_free(buffer1);
    
    return 0;
}


